package com.qf.day08;

import com.qf.day04.ArrUtils;
import com.qf.day06.Dog;

import java.util.Arrays;

/**
 * 接口的引例子
 * 数组的排序，如果数组中元素是对象，是否能进行排序
 */
public class Demo01 {
    public static void main(String[] args) {
//        int[] arr ={4,3,5,1,2};
//        //排序
//        Arrays.sort(arr);
//        ArrUtils.bl(arr);
//
//        //如果数组中的元素是引用类型的，是否能用上面的方法排序呢
//        String[] arr2 = {"luffy","lisi","ami","jack"};
//        Arrays.sort(arr2);
//        ArrUtils.printStringArr(arr2);

        Dog[] dogs = new Dog[3];
        Dog dog01 = new Dog("旺财", "哈士奇", "男", 5, "汪");
        Dog dog02 = new Dog("小黄", "牧羊犬", "男", 3, "ao");
        Dog dog03 = new Dog("小黑", "藏獒", "男", 2, "aoao");
        dogs[0] = dog01;
        dogs[1] = dog02;
        dogs[2] = dog03;
        for (int i = 0; i < dogs.length; i++) {
            System.out.println(dogs[i]);
        }
        //通过实现Comparable接口，指定了dog对象的比较逻辑，是按照年龄进行比较的
        Arrays.sort(dogs);
        for (int i = 0; i < dogs.length; i++) {
            System.out.println(dogs[i]);
        }


    }
}
